package com.hetao.xx.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hetao.xx.R;
import com.hetao.xx.orm.UserVo;

import java.util.List;

public class LoadPageAdapter extends BaseAdapter {

    private final List<UserVo> list;
    private final Context context;
    public LoadPageAdapter(Context context, List<UserVo> list) {
        this.context = context;
        this.list = list;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.layout_load_grid_item, null);
            holder = new ViewHolder();
            holder.textView = convertView.findViewById(R.id.load_grid_item);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.textView.setText(list.get(position).name);
        return convertView;
    }

    class ViewHolder {
        public TextView textView;

    }
}
